"""
@-*- coding: utf-8 -*-
@ python: 3.12.3
@ 创建者: JacksonCode
@ 创建时间: 2025/8/27
"""
import subprocess
from functools import partial
subprocess.Popen = partial(subprocess.Popen, encoding="utf-8")

import requests
import json
import execjs


js_code = open("xiniu.js").read()

js_compile = execjs.compile(js_code)

headers = {
    "accept": "application/json",
    "accept-language": "zh-CN,zh;q=0.9",
    "cache-control": "no-cache",
    "content-type": "application/json",
    "origin": "https://www.xiniudata.com",
    "pragma": "no-cache",
    "priority": "u=1, i",
    "referer": "https://www.xiniudata.com/industry/newest?from=data",
    "sec-ch-ua": "\"Not;A=Brand\";v=\"99\", \"Google Chrome\";v=\"139\", \"Chromium\";v=\"139\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-origin",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36"
}
# cookies = {
#     "btoken": "ZFYZ0XZLLLFNDU7NFVHGYOJ9NEMWABBC",
#     "Hm_lvt_42317524c1662a500d12d3784dbea0f8": "1756086193,1756256669",
#     "HMACCOUNT": "50AC8FFC6341318C",
#     "Hm_lpvt_42317524c1662a500d12d3784dbea0f8": "1756270417"
# }
url = "https://www.xiniudata.com/api2/service/x_service/person_industry_list/list_industries_by_sort"

params = {
    "sort": 1,
    "start": 40,
    "limit": 20
}

# obj = js_compile.call("getParams",json.dumps(params))
obj = js_compile.call("getParams", str(json.dumps(params)))
# obj = js_compile.call("getParams",params)
# print(obj)
# exit()

data = {
    "payload": obj["payload"],
    "sig": obj["s"],
    "v": 1
}
# print(data)
# exit()
data = json.dumps(data, separators=(',', ':'))
response = requests.post(url, headers=headers, data=data)

# print(response.text)
# print(response.json())
# print(response)
encrypt_data = response.json()['d']
# encrypt_data = response.json().get("d")
# print(encrypt_data)
# print(type(encrypt_data))
# exit()
decrypt_data = js_compile.call("getDecrypt", encrypt_data)
print(decrypt_data)
